home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / util / wb / autogui.lha / AutoGui / AutoGui.gc next >
Text File  |  2000-02-16  |  21KB  |  811 lines

  1. G4C
  2.  
  3. ; AutoGui.gc v 1.0 by dck@hol.gr   (Set TABs to 3)
  4. ; ------------------------------------------------------------
  5. ; This gui will take ask you for a program and then, from the
  6. ; command template of that program (if there is one) will
  7. ; construct a complete workable gui.
  8. ; ------------------------------------------------------------
  9.  
  10. WINBIG 121 24 227 154 'Automatic Guis Ltd.'
  11. WinType 11110001
  12. ResInfo 8 640 256
  13.  
  14. xOnClose
  15.     GuiQuit #This
  16.  
  17. xOnQuit
  18.     GuiQuit AutoPrefs
  19.     guiquit AutoEdit
  20.     guiquit AutoHelp
  21.     guiquit AutoSlider
  22.  
  23. xOnRMB
  24.     guiclose AutoHelp
  25.  
  26. ; ------------------------------------------------------------
  27. ;        STARTUP
  28. ; ------------------------------------------------------------
  29.  
  30. xOnLoad command
  31.     setgad #this 1/9 hide    ; hide lvs
  32.     setgadvalues #this
  33.     setgadvalues AutoPrefs    ; the other gui
  34.     setgad AutoPrefs 7 OFF    ; the box attr textin gad
  35.     guiopen #this
  36.     gosub #this GetCommand $command
  37.  
  38. xOnReload newcommand
  39.     guiopen #this
  40.     guiscreen #this front
  41.     if $newcommand > ''
  42.         command = $newcommand
  43.         newcommand = ''
  44.         gosub #this GetCommand $command
  45.     endif
  46.  
  47. ; ------------------------------------------------------------
  48. ;        The GUI
  49. ; ------------------------------------------------------------
  50.  
  51. XTEXTIN 0 0 212 14 "" outfile "(Enter GuiFile name)" 130
  52.     gadhelp 'Enter the name of the Gui to be created'
  53.     attr resize 0020
  54.     gadid 15
  55.  
  56. XBUTTON 212 0 14 14 "<"
  57.     gadhelp 'Choose the directory into which to save the Gui'
  58.     attr resize 2000
  59.     ReqFile -1 -1 300 -40 "Choose Directory for gui" DIR dirname ""
  60.     joinfile $dirname $comname\.gc outfile
  61.     Update #this 15 $outfile
  62.  
  63. XLISTVIEW 0 14 125 140 "" lvargs "" 0 SHOW
  64.     gadhelp 'These are the Command Line Arguments in standard Amiga format'
  65.     attr resize 0022
  66.     gadid 10
  67.  
  68. XBUTTON 126 14 50 14 "Up"
  69.     gadhelp 'Move currently selected argument UP in list'
  70.     attr resize 2000
  71.     lvuse #this 10
  72.     if $$lv.line <= 0 ; top line..
  73.         stop
  74.     endif
  75.     temp = $$lv.rec
  76.     lvgo prev
  77.     temp2 = $$lv.rec
  78.     lvput $temp
  79.     lvgo next
  80.     lvput $temp2
  81.     lvgo prev
  82.     lvmove 0
  83.  
  84. XBUTTON 177 14 49 14 "Down"
  85.     gadhelp 'Move currently selected argument DOWN in list'
  86.     attr resize 2000
  87.     lvuse #this 10
  88.     temp == $$lv.tot - 1
  89.     if $$lv.line >= $temp ; bottom line..
  90.         stop
  91.     endif
  92.     temp = $$lv.rec
  93.     lvgo next
  94.     temp2 = $$lv.rec
  95.     lvput $temp
  96.     lvgo prev
  97.     lvput $temp2
  98.     lvgo next
  99.     lvmove 0
  100.  
  101. XBUTTON 126 28 50 14 "Edit"
  102.     gadhelp 'Edit currently selected argument'
  103.     attr resize 2000
  104.     guiopen AutoEdit AutoGui.gc PutToList "Edit command option:" $AutoGui.gc/lvargs
  105.     xRoutine PutToList
  106.         lvuse #this 10
  107.         lvput $AutoEdit/string
  108.  
  109. XBUTTON 177 28 49 14 "Add"
  110.     gadhelp 'Add a Command line argument - in standard Amiga format'
  111.     attr resize 2000
  112.     guiopen AutoEdit AutoGui.gc AddToList "Add a CLI command option:" ""
  113.     xRoutine AddToList
  114.         lvuse #this 10
  115.         lvadd $AutoEdit/string
  116.  
  117. XBUTTON 177 42 49 14 "Com"
  118.     gadhelp 'Manually enter the name of the command (or program) to run'
  119.     attr resize 2000
  120.     guiopen AutoEdit AutoGui.gc SetCommName "Enter full path & name of Command:" ""
  121.     xRoutine SetCommName
  122.         compath = $AutoEdit/string
  123.         extract compath file comname
  124.         SetWinTitle #this $comname
  125.         extract compath path outfile
  126.         joinfile $outfile $comname\.gc outfile
  127.         update #this 15 $outfile
  128.  
  129. XBUTTON 126 42 50 14 "Del"
  130.     gadhelp 'Remove currently selected argument from the list'
  131.     attr resize 2000
  132.     lvuse #this 10
  133.     lvdel -1
  134.     lvgo next
  135.     lvmove 0
  136.  
  137. XBUTTON 126 56 100 14 "Prefs.."
  138.     gadhelp 'Adjust the look of the gui in various ways' 
  139.     attr resize 2000
  140.     guiopen AutoPrefs
  141.  
  142. XTEXTBOX 126 84 100 42 "" ""
  143.      attr resize 2002
  144.      attr tbox 2/1/3/button/out
  145.  
  146. XBUTTON 126 126 100 14 "New.."
  147.     gadhelp 'Choose a new command to give a gui to - it will be run to get its arguments'
  148.     attr resize 2200
  149.     gosub #this GetCommand ''
  150.     update autoprefs 8 '' ; reset helpfile
  151.  
  152. ; ------------------------------------------------------------
  153. ;         CREATE the gui
  154. ; ------------------------------------------------------------
  155.  
  156. XBUTTON 126 140 100 14 "Create!"
  157.     gadhelp 'Create  a Gui, based on the arguments listed'
  158.     attr resize 2200
  159.     local botpos/srcicon/desticon
  160.  
  161.     gosub #this ResetSizes    ; get default sizes
  162.  
  163.     ; Start constructing file (TOP/BOT at lines 14/15 - no change!)
  164.     .temp = 'G4C\n\nWinBig\nWinType 11110001\nResInfo $fontsize $screenx $screeny\n\nxOnLoad\n\tGuiOpen #this\n\nxOnClose\n\tGuiQuit #this\n\n; Decorative TextBoxes\nTOP\nBOT\n'
  165.     lvuse #this 1
  166.     lvchange env:.temp
  167.     delvar .temp
  168.     ; set winfont
  169.     if $AutoPrefs/font > ''
  170.         lvadd 'WinFont $AutoPrefs/font 000\n'
  171.     endif
  172.     lvadd '; -------------------- Gadgets ---------------------\n'
  173.  
  174.     lvuse #this 10            ; add all gadgets..
  175.     if $$lv.tot = 0
  176.         stop ; no args..
  177.     endif
  178.     lvgo first
  179.     while $$lv.line > ''
  180.         arg = $$lv.rec
  181.         if $arg > ' ' ; skip blanks..
  182.             gosub #this addgadget
  183.         endif
  184.         lvuse #this 10
  185.         lvgo next
  186.     endwhile
  187.  
  188.     ; add top box
  189.     gosub #this GetPosition $width $ysize
  190.     ++ypos ; leave a pixel..
  191.     lvuse #this 1
  192.  
  193.     ; edit top box line
  194.     lvgo #13
  195.     lvput 'xTextBox 0 0 0 $ypos "" ""\n\tAttr TBox $autoprefs/topbox'
  196.  
  197.     if $AutoPrefs/pipe = ON
  198.         lvadd '; -------------------- Pipe: Output --------------------'
  199.         lvadd ''
  200.         lvadd 'xPIPE PIPE:$comname ON\n\tGadID 901\n\tUpdate #this 902 \$\$pipe.txt\n'
  201.         lvadd 'xTextBox 0 $ypos 0 $tiheight "" "Idle."'
  202.         lvadd '\tAttr TBox $autoprefs/midbox\n\tGadID 902\n'
  203.         ypos = $($ypos + $tiheight)
  204.     endif
  205.     botpos = $ypos
  206.  
  207.     ; add the command construction & execute code (lv2)
  208.     lvadd '; -------------------- Execution ---------------------\n'
  209.     ypos = $($ypos + $ydist + 1)
  210.     lvadd 'xBUTTON $($winmargin +3) $ypos 80 $ysize Execute'
  211.     lvadd '\tcomline = ""'
  212.     lvuse #this 2
  213.     lvgo first
  214.     lvclip cut -1 add #this 1
  215.     lvuse #this 1
  216.     lvadd "\tSetStack $AutoPrefs/stack"
  217.     if $AutoPrefs/pipe = ON
  218.         lvadd "\tRUN '$compath >PIPE:$comname \$comline'"
  219.     else
  220.         lvadd "\tRUN '$compath \$comline'"
  221.     endif
  222.     lvadd "\tSetStack 4096" ; reset to default..
  223.  
  224.     ; add the CANCEL button
  225.     lvadd '\nxBUTTON $($width - 80 - $winmargin -3) $ypos 80 $ysize Abort'
  226.     lvadd '\tBreakTask $compath CD'
  227.  
  228.     ; add a HELP button, if defined
  229.     if $autoprefs/helpfile > ''
  230.         lvadd '\nxBUTTON $($winmargin +84) $ypos 60 $ysize Help..'
  231.         lvadd '\tRun "multiview $autoprefs/helpfile"'
  232.     endif
  233.  
  234.     ; change winbig line..
  235.     lvgo #2
  236.     ypos = $($ypos + $ysize + $ydist + 1) ; total height..
  237.     lvput 'WinBig -1 -1 $width $ypos "Gui 4 $comname"'
  238.  
  239.     ; add bottom box (to the top of file)
  240.     lvgo #14
  241.     lvput 'xtextbox 0 $botpos 0 $($ypos - $botpos) "" ""\n\tAttr TBox $autoprefs/botbox'
  242.  
  243.     ; Add command to set the 1st textin gadget on..
  244.     if $firstgad > 0
  245.         lvgo #7
  246.         lvput '\tGuiOpen #this\n\tSetGad #this $firstgad ON'
  247.     endif
  248.  
  249.     ; save file..
  250.     lvadd '\n'
  251.     lvsave $outfile
  252.  
  253.     ; start (or re-start) gui..
  254.     extract outfile file outname
  255.     ifexists gui $outname
  256.         guiclose $outname
  257.         guirename $outname gui_dead
  258.         guiquit gui_dead
  259.     endif
  260.     guiload $outfile
  261.  
  262.     ; save icon if wanted..
  263.     if $autoprefs/icon = ON
  264.         extract #this guipath srcicon
  265.         joinfile $srcicon DefGuiIcon srcicon
  266.         extract outfile path desticon
  267.         joinfile $desticon $outname\.info desticon
  268.         copy $srcicon $desticon
  269.     endif
  270.  
  271. ; ------------------------------------------------------------
  272. ;        Invisible LISTVIEWS
  273. ; ------------------------------------------------------------
  274.  
  275. ; used for file handling
  276. XLISTVIEW 0 0 257 131 '' line '' 0 MULTI
  277.     gadid 1
  278.  
  279. ; for storing commandline construction code
  280. XLISTVIEW 0 0 257 131 '' line '' 0 MULTI
  281.     gadid 2
  282.  
  283. ; ------------------------------------------------------------
  284. ;         GET COMMAND & extract the template into lv10
  285. ; ------------------------------------------------------------
  286.  
  287. xROUTINE GetCommand command
  288.     if $command = ''
  289.         ; get the command..
  290.         reqfile -1 -1 300 -40 'Choose command:' LOAD command c:
  291.         if $command = ''
  292.             return
  293.         endif
  294.     endif
  295.     compath = $command
  296.     extract compath file comname 
  297.  
  298.     ; get the command template
  299.     failat 25 ; so that failures do not stop us..
  300.     setstack $AutoPrefs/stack
  301.     cli '$command ? >T:temp <NIL:'
  302.     setstack 4096
  303.     lvuse #this 1
  304.     lvchange T:temp
  305.     lvgo first
  306.     command = $$lv.rec
  307.     if $command = '' ; nothing..
  308.         return
  309.     endif
  310.  
  311.     ; get all commandline args into listview
  312.     lvuse #this 10
  313.     lvclear
  314.  
  315.     ; replace all comas with spaces, so as to separate args
  316.     repvar command ',' ' ' cs
  317.     cutvar command cut word 1 arg            ; get 1st argument
  318.     while $arg > ' '
  319.         extract arg clean arg                ; clean surrounding spaces
  320.         if $arg[-1][1] = ':'                    ; its the last arg..
  321.             cutvar arg cut char -1 ''      ; crop trailing ':'
  322.             command = ''                         ; ensure endwhile
  323.         endif
  324.  
  325.         ; check for '=' and keep last part
  326.         repvar arg '=' ' ' cs
  327.         parsevar arg
  328.         if $$parse.tot > 1
  329.             cutvar arg cut word -1 arg
  330.             extract arg clean arg
  331.         endif
  332.  
  333.         lvadd '$arg'
  334.         cutvar command cut word 1 arg        ; get next argument
  335.     endwhile
  336.  
  337.     ; update output name (keep path)
  338.     outfile = $compath\.gc
  339.     update #this 15 $outfile
  340.     Setwintitle #this $comname
  341.     failat 10
  342.  
  343. xonfail
  344.     ezreq "If you get this error when you choose a\nnew command, it's ok.. I ran the command\nto get its template." Phew!.. ''
  345.  
  346. ; ------------------------------------------------------------
  347. ;        ADD A GADGET (according to arg type)
  348. ; ------------------------------------------------------------
  349.  
  350. xROUTINE addgadget ; argument is in arg
  351.     local c/type/musthave/isnum/x/w/style
  352.     lvuse #this 1
  353.     ; split arg at the /
  354.     repvar arg '/' ' ' cs
  355.     parsevar arg
  356.     name = $$parse.0
  357.  
  358.     ; convert name to title/lowercase (looks better)
  359.     extract name lower name
  360.     temp = $name[0][1]
  361.     extract temp upper temp
  362.     name[0][1] = $temp
  363.  
  364.     musthave = 0
  365.     multi    = 0
  366.     isnum    = 0
  367.     type     = 'I'        ; I=anything..
  368.  
  369.     ; go through all readargs switches, changing above defaults..
  370.     c = 1
  371.     while $c <= $$parse.tot    
  372.         temp = '\$\$parse.$c'
  373.         extract temp upper temp
  374.         ; do special cases..
  375.         if $temp = 'T'             ; toggle is same as switch
  376.         or $temp = 'S'
  377.             type = 'S'
  378.         elseif $temp = 'M'    ; both taken as multi
  379.         or $temp = 'F'
  380.             multi = 1
  381.         elseif $temp = 'N'
  382.             isnum = 1
  383.         elseif $temp = 'A'
  384.             musthave = 1
  385.         elseif $temp = 'K'
  386.             type = 'K'
  387.         endif
  388.         ++c
  389.     endwhile
  390.  
  391.     ; set type of title
  392.     titstyle = $AutoPrefs/titstyle
  393.     style = "2/1/shadow/lside/middle/$name" ; default
  394.     if $titstyle = PLAIN
  395.         style = "1/1/plain/lside/middle/$name"
  396.     elseif $titstyle = WHITE
  397.         style = "2/1/plain/lside/middle/$name"
  398.     elseif $titstyle = OUTLINE
  399.         style = "2/1/outline/lside/middle/$name"
  400.     elseif $titstyle = OUTLINE2
  401.         style = "3/1/outline/lside/middle/$name"
  402.     endif
  403.  
  404.     ; ----- add gadgets as per type..
  405.  
  406.     if $type = 'S'                                ; SWITCHES 
  407.         gosub #this GetPosition $cbwidth $cbheight
  408.         lvadd "xCheckBox $xpos $ypos $cbwidth $cbheight '' $name $name '' OFF"
  409.         lvadd    '\tAttr Title $style'
  410.         ; comline contruction instructions
  411.         lvuse #this 2
  412.         lvadd '\tIf \$$name > ""'
  413.         lvadd '\t\tAppVar comline " $name"'
  414.         lvadd '\tEndif'
  415.         lvuse #this 1
  416.  
  417.     else                                            ; KEYWORDS & PLAIN
  418.         ; see which width to use..
  419.         w = $tiwidth
  420.         if $isnum = 1
  421.             w = $niwidth
  422.         endif
  423.         gosub #this GetPosition $w $tiheight
  424.         lvadd "xTextIn  $xpos $ypos $w $tiheight '' $name '' 100"
  425.         lvadd    '\tAttr Title $style'
  426.         if $isnum = 1                                ; add number filter
  427.             lvadd '\tAttr TIType INT'
  428.         else    ; if its not a number gadget, add file request button..
  429.             temp = $($xpos + $w +1) ; to pass as argument..
  430.             gosub #this addreq $temp $multi
  431.         endif
  432.  
  433.         lvuse #this 2                                ; add execution code..
  434.         lvadd '\tIf \$$name > ""'
  435.  
  436.         ; append the commandline option..
  437.         if $type = 'K' ; give keyword
  438.             lvadd '\t\tAppVar comline " $name\=\$$name"'
  439.         else
  440.             lvadd '\t\tAppVar comline " \$$name"'
  441.         endif
  442.  
  443.         ; if its /A, it obligatory..
  444.         if $musthave = 1
  445.             lvadd '\tElse'
  446.             lvadd '\t\tEzReq "Incomplete argument:\\nOption <$name\> must be given!" OK ""'
  447.             lvadd '\t\tStop'
  448.         endif
  449.  
  450.         lvadd '\tEndif'
  451.         lvuse #this 1
  452.     endif
  453.     lvadd '' ; blank line..
  454.  
  455. ; ------------------------------------------------------------
  456. ; --------- Add a file requester to xtextin gads
  457. ; ------------------------------------------------------------
  458.  
  459. xRoutine AddReq ; pass: $$arg.0=leftpos $$arg.1=multi
  460.     lvadd '\tGadID $gadcount'
  461.     lvadd ''
  462.     lvadd 'xBUTTON $$arg.0 $ypos 15 $tiheight "<"'
  463.     if $$arg.1 = 1
  464.         lvadd '\tReqFile -1 -1 300 -40 "Select $name (multiple)" MULTI $name ""'
  465.     else
  466.         lvadd '\tReqFile -1 -1 300 -40 "Choose a $name" LOAD $name ""'
  467.     endif
  468.     lvadd '\tUpdate #this $gadcount \$$name'
  469.     ++gadcount
  470.  
  471. ; ------------------------------------------------------------
  472. ; --------- calc the X,Y position...
  473. ; ------------------------------------------------------------
  474.  
  475. xRoutine GetPosition gw gh
  476.     local sameline
  477.     if $ypos = 0    ; first time..
  478.         xpos = $($winmargin + $titmargin)
  479.         ypos == $ydist + 2
  480.         sameline = 1
  481.     ; see if it fits, width wise..
  482.     elseif $($xpos + $lastgadwidth + $titmargin + $gw + $winmargin) < $width
  483.         xpos = $($xpos + $lastgadwidth + $titmargin) ; add xdist??
  484.         ; ypos remains unchanged..
  485.         sameline = 1
  486.     else
  487.         xpos = $($winmargin + $titmargin)
  488.         ypos = $($ypos + $lastgadheight + $ydist)
  489.         sameline = 0
  490.     endif
  491.     if $sameline = 0                ; if >1 gads on same line, remember
  492.         lastgadheight = $gh        ; the tallest height for next line..
  493.     else
  494.         if $lastgadheight < $gh
  495.             lastgadheight = $gh
  496.         endif
  497.     endif
  498.     lastgadwidth  = $gw
  499.  
  500. ; ------------------------------------------------------------
  501. ;        GET SIZES & DISTANCES
  502. ; ------------------------------------------------------------
  503.  
  504. xROUTINE ResetSizes
  505.     info gui #this                            ; get info from the front screen
  506.     maxheight == $$screen.h - 30        ; max gui height
  507.     ysize == $$screen.bar + 3            ; gadget height (buttons etc)
  508.     screenx = $$screen.w                    ; get these for resinfo..
  509.     screeny = $$screen.h
  510.     fontsize == $$screen.bar - 2
  511.  
  512.     ; get settings from AutoPrefs gui
  513.     width     = $autoprefs/width
  514.     winmargin = $autoprefs/winmargin
  515.     titmargin = $autoprefs/titmargin 
  516.     ydist     = $autoprefs/ydist
  517.  
  518.     ; calculate various positions from above info..
  519.     xpos = $($winmargin + $titmargin)
  520.     ypos = 0 ; used as first time flag..
  521.  
  522.     ; initialize sizes for textin gads
  523.     tiwidth  = $($width - $xpos - 18 - $winmargin)
  524.     tiheight == $$screen.bar + 4
  525.     niwidth  = $($$screen.bar * 10) ; number gadgets??
  526.  
  527.     ; initialize these for checkboxes..
  528.     cbpos    =  0
  529.     cbheight ==    $$screen.bar + 2
  530.     cbwidth  == $screenx / 27    ; approximate.. 
  531.     cbstep   = $($titmargin + $cbwidth + 1)
  532.  
  533.     gadcount = 1        ; for giving gadids
  534.     lastgadheight = 0    ; for GetPosition()
  535.     lastgadwidth  = 0
  536.     firstgad = 0        ; for setgading the 1st textbox
  537.  
  538. ; ------------------------------------------------------------
  539. ;        HELP
  540. ; ------------------------------------------------------------
  541.  
  542. XBUTTON 126 70 73 14 Help
  543.     attr resize 2000
  544.     local guidename/mypath
  545.     gadhelp 'Load the AutoGui guide'
  546.     extract #this guipath mypath
  547.     joinfile $mypath AutoGui.guide guidename
  548.     ifexists file $guidename
  549.         run 'multiview $guidename'
  550.     else
  551.         ezreq 'The AutoGui guide was not found..\nFile: $guidename' Ok ''
  552.     endif 
  553.  
  554. XCHECKBOX 200 70 26 14 "" help "ON" "OFF" OFF
  555.     attr resize 2000
  556.     gadhelp 'Help is now $help'
  557.     if $help = ON
  558.         setgad #this 55 ON
  559.     else
  560.         guiclose AutoHelp
  561.         setgad #this 55 OFF
  562.     endif
  563.  
  564. xOnHelp OFF
  565.     gadid 55
  566.     local oldtext
  567.     if $$help.text != $oldtext
  568.         guiclose AutoHelp
  569.         guiopen AutoHelp $$help.text AutoGui.gc
  570.         oldtext = $$help.text
  571.     endif
  572.  
  573.  
  574. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  575. ; ===============================================================
  576.  
  577.     NEWFILE AutoEdit        ; Edit strings
  578.  
  579. ; ===============================================================
  580. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  581.  
  582. WINBIG 65 109 436 14 ""
  583. WinType 11110010
  584. resinfo 8 640 256
  585.  
  586. xOnOPEN  gui rtn title string
  587.     guiopen #this
  588.     guiwindow AutoGui.gc wait
  589.     setwintitle #this '$title'
  590.     update #this 1 $string
  591.     setgad #this 1 ON
  592.  
  593. xOnClose
  594.     guiwindow AutoGui.gc Resume
  595.  
  596. XTEXTIN 0 0 0 0 "" string "" 150
  597.     gadid 1
  598.     guiclose #this
  599.     gosub $gui $rtn
  600.  
  601.  
  602. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  603. ; ===============================================================
  604.  
  605.     NEWFILE AutoHelp        ; Show help boxes..
  606.  
  607. ; ===============================================================
  608. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  609.  
  610. winbig 0 0 180 50 ''
  611. wintype 000010
  612. resinfo 8 640 256
  613. winonmouse -20 12
  614.  
  615. xOnRMB
  616.     guiclose #this
  617.  
  618. xOnOpen text gui
  619.     ; info variable text
  620.     ; width = $(($$var.length * 8) + 6)    ; using 8 point font..
  621.     update #this 1 '$text'
  622.     guiwindow $gui on
  623.  
  624. xTEXTBox 0 0 0 0 '' ''
  625.     gadid 1
  626.     attr tbox 2/1/3/button/out
  627.     ; attr tbstyle 2/1/shadow/center
  628.     attr tbstyle 2/1/plain/center
  629.  
  630.  
  631. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  632. ; ===============================================================
  633.  
  634.     NEWFILE AutoSlider        ; Get a numeric argument
  635.  
  636. ; ===============================================================
  637. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  638.  
  639. WINBIG 112 69 342 14 ""
  640. WinType 11110010
  641. WinOnMouse 200 7
  642. resinfo 8 640 256
  643. BOX 267 0 41 14 out button
  644.     attr resize 2002
  645.  
  646. xOnOPEN  gui rtn title min max newval
  647.     guiwindow $gui wait
  648.     changearg #this 1 7 $max
  649.     changearg #this 1 6 $min
  650.     guiopen #this
  651.     update #this 1 $newval
  652.     redraw #this
  653.     setwintitle #this '$title ($min\-$max\)'
  654.  
  655. xOnClose
  656.     guiwindow $gui Resume
  657.  
  658. XHSLIDER 0 0 267 14 '' val 0 100 50 "%ld"
  659.     attr resize 0022
  660.     gadid 1
  661.  
  662. XBUTTON 309 0 32 14 Ok
  663.     attr resize 2002
  664.     guiclose #this
  665.     gosub $gui $rtn
  666.  
  667.  
  668. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  669. ; ===============================================================
  670.  
  671.     NEWFILE AutoPrefs        ; various settings
  672.  
  673. ; ===============================================================
  674. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  675.  
  676. WINBIG 101 35 436 133 AutoPrefs
  677. WinType 11110001
  678. ResInfo 8 640 256
  679. BOX 0 0 436 133 out button
  680.  
  681. XTEXTIN 136 6 50 14 "" width "300" 10                            ; WIDTH
  682.     Attr Title '2/1/shadow/lside/middle/Gui width:'
  683.     Attr TIType INT
  684.     gadid 1
  685. XBUTTON 188 6 15 14 "<"
  686.     guiopen AutoSlider AutoPrefs SetWidth "Set Gui width:" 150 620 $width
  687.     xRoutine SetWidth
  688.         width = $AutoSlider/val
  689.         update #this 1 $width
  690.  
  691. XTEXTIN 136 20 50 14 "" winmargin "5" 10                        ; WINMARGIN
  692.     Attr Title '2/1/shadow/lside/middle/Window margins:'
  693.     Attr TIType INT
  694.     gadid 2
  695. XBUTTON 188 20 15 14 "<"
  696.     guiopen AutoSlider AutoPrefs SetWinMargin "Set window margins:" 0 20 $winmargin
  697.     xRoutine SetWinMargin
  698.         winmargin = $AutoSlider/val
  699.         update #this 2 $winmargin
  700.  
  701. XTEXTIN 136 34 50 14 "" titmargin "65" 10                        ; TITMARGINS
  702.     Attr Title '2/1/shadow/lside/middle/Title margins:'
  703.     Attr TIType INT
  704.     gadid 3
  705. XBUTTON 188 34 15 14 "<"
  706.     guiopen AutoSlider AutoPrefs SetTit "Set margin to leave for titles:" 40 150 $titmargin
  707.     xRoutine SetTit
  708.         titmargin = $AutoSlider/val
  709.         update #this 3 $titmargin
  710.  
  711. XTEXTIN 136 48 50 14 "" ydist "3" 10                            ; YDIST
  712.     Attr Title '2/1/shadow/lside/middle/Gadget distance:'
  713.     Attr TIType INT
  714.     gadid 4
  715. XBUTTON 188 48 15 14 "<"
  716.     guiopen AutoSlider AutoPrefs SetYDist "Distance between gadgets:" 0 20 $ydist
  717.     xRoutine SetYDist
  718.         ydist = $AutoSlider/val
  719.         update #this 4 $ydist
  720.  
  721. XTEXTIN 345 6 58 14 "" stack "4096" 10                            ; STACK
  722.      Attr Title '2/1/shadow/lside/middle/Program Stack:'
  723.      Attr TIType INT
  724.      gadid 5
  725. XBUTTON 408 6 15 14 "<"
  726.      guiopen AutoSlider AutoPrefs SetStack "Set Stack (Kbytes) for the program:" 3 30 $($stack / 1024)
  727.      xRoutine SetStack
  728.         stack = $($AutoSlider/val * 1024)
  729.          update #this 5 $stack
  730.  
  731. ; XTEXTIN 345 21 50 14 "" "winmargin" "5" 10
  732. ; XBUTTON 396 21 15 14 "<"
  733. ; XTEXTIN 345 36 50 14 "" "winmargin" "5" 10
  734. ; XBUTTON 396 36 15 14 "<"
  735. ; XTEXTIN 345 51 50 14 "" "winmargin" "5" 10
  736. ; XBUTTON 396 51 15 14 "<"
  737.  
  738. ; -------- textbox & title styles
  739.  
  740. CTEXT 51 70 "Box Attributes:" #screen 8 2 -1 00011
  741.  
  742. XTEXTIN 51 81 155 13 "" topbox "2/1/0/button/out" 100
  743.      Attr Title '2/1/shadow/lside/middle/Top'
  744.  
  745. XTEXTIN 51 96 155 14 "" midbox "2/1/0/button/out" 100
  746.      Attr Title '2/1/shadow/lside/middle/Mid'
  747.     gadid 7
  748.  
  749. XTEXTIN 51 111 155 14 "" "botbox" "2/1/3/button/out" 100
  750.      Attr Title '2/1/shadow/lside/middle/Bot'
  751.  
  752.  
  753. XCYCLER 276 54 147 14 "" titstyle
  754.     CSTR Shadow      SHADOW 
  755.     CSTR Plain       PLAIN
  756.     cstr White       WHITE
  757.    cstr Outline     OUTLINE
  758.    cstr Outline2    OUTLINE2
  759.      Attr Title '2/1/shadow/lside/middle/Titles:'
  760.  
  761. ; -------- font
  762.  
  763. XTEXTIN 276 39 130 14 "" font "" 100
  764.      Attr Title '2/1/shadow/lside/middle/Font:'
  765.      gadid 6
  766. XBUTTON 408 39 15 14 "<"
  767.     local myfont/size
  768.     myfont = ''
  769.     ReqFile -1 -1 300 -40 'Choose a Font (size):' LOAD myfont FONTS:
  770.     if $myfont > ''
  771.         extract myfont file size
  772.         extract myfont path myfont
  773.         extract myfont file myfont
  774.         appvar  myfont .font
  775.         font = "$myfont $size"
  776.         update #this 6 $font
  777.     endif
  778.  
  779. ; ----------- add pipe
  780.  
  781. XCHECKBOX 396 21 26 14 "" pipe "ON" "OFF" OFF
  782.      Attr Title '2/1/shadow/lside/middle/Add Pipe: Output'
  783.     if $pipe = ON
  784.         setgad #this 7 ON            ; enable box attr gadget
  785.     else
  786.         setgad #this 7 OFF
  787.     endif
  788.  
  789. ; ----------- add a Help file
  790.  
  791. XTEXTIN 276 69 130 14 "" helpfile "" 130
  792.     gadhelp 'Add a button to load Help file for command'
  793.      Attr Title '2/1/shadow/lside/middle/Help'
  794.     gadid 8
  795. XBUTTON 408 69 15 14 "<"
  796.     gadhelp 'Choose a Help file'
  797.     helpfile = ''
  798.     ReqFile -1 -1 300 -40 'Choose a Help file:' LOAD helpfile ''
  799.     update #this 8 $helpfile
  800.  
  801. ; ----------- add icon
  802.  
  803. XCHECKBOX 396 85 26 14 "" icon "ON" "OFF" OFF
  804.      Attr Title '2/1/shadow/lside/middle/Add Icon'
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.